package com.example.aircraftwar.application.network;

import android.util.Log;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.Socket;

public class NetConn extends Thread {
    public static PrintWriter writer = null;
    public static BufferedReader reader = null;
    //10.249.57.174
    @Override
    public void run() {
        try {
            Socket socket = new Socket();
//            socket.connect(new InetSocketAddress("10.249.57.174", 9999), 5000);
            socket.connect(new InetSocketAddress("10.250.202.101", 9999), 5000);
            try{
                reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                Log.i("net", "reader init ok");
            }catch (IOException ex){
                ex.printStackTrace();
            }
            writer = new PrintWriter(new BufferedWriter(
                    new OutputStreamWriter(
                            socket.getOutputStream(),"UTF-8")),true);
//            // 发送登录请求
//            writer.println("login");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
